package com.IntelligentCommunity.algorithm.controller;

import com.IntelligentCommunity.algorithm.domain.FaceImgResponse;
import com.IntelligentCommunity.algorithm.domain.FaceRecognitionConf;
import com.IntelligentCommunity.algorithm.domain.request.FaceAddRequest;
import com.IntelligentCommunity.algorithm.service.AlgorithmService;
import com.IntelligentCommunity.common.core.domain.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;


/**
 * @author 美国五星上将麦克阿瑟
 */
@RestController
@RequestMapping("/face")
public class AlgorithmController {

    @Autowired
    private AlgorithmService algorithmService;


    /**
     * 添加人脸照片
     * @param faceAddRequest
     * @return
     */
    @PostMapping("/faceAdd")
    public R faceInsert(@RequestBody FaceAddRequest faceAddRequest){
        return R.ok(algorithmService.faceAdd(faceAddRequest));
    }

    /**
     * 批量添加人脸照片
     * @return
     */
    @PostMapping("/faceAddBath")
    public R faceInsertBath(@RequestBody List<FaceAddRequest> faceAddRequestList){
        return R.ok(algorithmService.faceAddBath(faceAddRequestList));
    }

    /**
     * 删除人脸照片
     * @param imageId
     * @return
     */
    @DeleteMapping("/faceDel")
    public R faceDel(@RequestParam String imageId){
        return R.ok(algorithmService.faceDel(imageId));
    }


    /**
     * 比对人脸照片
     * @return
     */
    @PostMapping("/faceRec")
    public R faceRec(@RequestBody FaceRecognitionConf faceRecognitionConf){
        return R.ok(algorithmService.faceRec(faceRecognitionConf));
    }

    /**
     * 查询人脸照片
     * @return
     */
    @GetMapping("/faceFindBySubject")
    public R<FaceImgResponse> faceFindBySubject(@RequestParam("subjectName") String subjectName){
        return R.ok(algorithmService.faceFindBySubject(subjectName));
    }


    /**
     * 人脸识别
     */
    @PostMapping("/faceDet")
    public R faceDet(@RequestBody FaceRecognitionConf faceRecognitionConf){
        return R.ok(algorithmService.faceDet(faceRecognitionConf));
    }

    /**
     * 按名称删除主题的所有示例
     */
    @PostMapping("/delBySubject")
    public R delBySubject(@RequestParam String subject){
        algorithmService.delBySubject(subject);
        return R.ok();
    }

    /**
     * 按名称批量删除主题的所有示例
     */
    @PostMapping("/delBySubjects")
    public R delBySubjects(@RequestParam("subject") List<String> subjects){
        algorithmService.delBySubjects(subjects);
        return R.ok();
    }


}
